<template>
  <div class="com-step">
    <!-- <div class="base-line"></div> -->
    <div
      v-for="(s, i) in steps"
      :key="i"
      :class="{active: i <= active, current: i === active}"
      class="item"
    >
      <div class="date-time">
        <div>{{ s.time.split(' ')[0] }}</div>
        <div>{{ s.time.split(' ')[1] }}</div>
      </div>
      <div class="step">
        <div class="line"></div>
        <div class="index box-shadow" @click="clickHandle(i)">{{ i + 1 }}</div>
      </div>
      <div class="name">{{ s.name }}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    active: {
      type: Number,
      default: 0
    },
    steps: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickHandle(index) {
      this.$emit("index-change", index);
    }
  }
};
</script>

<style lang="scss" scoped>
$active-color: #35ad45;
.com-step {
  display: flex;
  .item {
    flex: 1;
    position: relative;
    text-align: center;
    color: #7f8fa4;
    .date-time {
      height: 40px;
      width: 100%;
    }
    .name {
      height: 20px;
      width: 100%;
    }
    .step {
      height: 48px;
      display: flex;
      align-items: center;
      overflow: hidden;
      position: relative;
      .line {
        height: 10px;
        width: 100%;
        background: #e9e9e9;
      }
      .index {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 30px;
        height: 30px;
        border-radius: 15px;
        border: 1px solid;
        color: #999999;
        background-color: #fff;
        line-height: 30px;
        font-size: 22px;
        cursor: pointer;
      }
    }
    &:first-child {
      .line {
        border-top-left-radius: 5px;
        border-bottom-left-radius: 5px;
      }
    }
    &:last-child {
      .line {
        border-top-right-radius: 5px;
        border-bottom-right-radius: 5px;
      }
    }
    &.active {
      color: $active-color;
      .line {
        background-color: $active-color;
      }
      .index {
        background: $active-color;
        color: #fff;
        border: 0;
      }
    }
    &.current {
      .index {
        width: 40px;
        height: 40px;
        border-radius: 20px;
        line-height: 40px;
      }
    }
  }
}
</style>
